package com.tianji.remark.service.impl;

/**
 * <p>
 * 点赞记录表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-04-10
 */
/*@Service
@Slf4j
@RequiredArgsConstructor
public class LikedRecordServiceImpl extends ServiceImpl<LikedRecordMapper, LikedRecord> implements ILikedRecordService {
    private final StringRedisTemplate redisTemplate;
    *//*private static final  ThreadPoolExecutor executor=new ThreadPoolExecutor(
            2,
            5,
            3,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(3),//阻塞队列容量
            new ThreadPoolExecutor.DiscardPolicy()//拒绝策略
    );
    private final RabbitMqHelper rabbitMqHelper;*//*
    @Override
    public void addLikeRecord(LikeRecordFormDTO recordDTO) {
        //1.获取当前登录用户id
        Long userId = UserContext.getUser();
        //2.判断是点赞还是取消点赞
        if (recordDTO.getLiked()){
            //2.1.点赞
            liked(userId,recordDTO);
        }else {
            //2.2.取消点赞
            unLiked(userId,recordDTO);
        }
        //3.统计点赞数
       // countAndSendLikedNums(recordDTO);
       *//* Long count = redisTemplate.opsForZSet().size(LIKE_BIZ_KEY_PREFIX + recordDTO.getBizId());
        if (count == null){
            count = 0L;
        }
        redisTemplate.opsForZSet().add(
                LIKE_COUNT_KEY_PREFIX+ recordDTO.getBizType(),
                recordDTO.getBizId().toString(),
                count
        );*//*
    }

    @Override
    public void readLikedTimesAndSendMessage(String bizType,Integer maxSize) {
        String key= LIKE_COUNT_KEY_PREFIX+ bizType;
        //从redis中获取点赞数
    }

    @Override
    public Set<Long> isBizLiked(List<Long> bizIds) {
        // 1.获取登录用户id
        Long userId = UserContext.getUser();
        // 2.查询点赞状态
        List<LikedRecord> list = lambdaQuery()
                .in(LikedRecord::getBizId, bizIds)
                .eq(LikedRecord::getUserId, userId)
                .list();
        // 3.返回结果
        return list.stream().map(LikedRecord::getBizId).collect(Collectors.toSet());
    }
    // 3.统计点赞数


    void unLiked(Long userId, LikeRecordFormDTO recordDTO) {
        String key = LIKE_BIZ_KEY_PREFIX + recordDTO.getBizId();
          redisTemplate.opsForZSet().remove(key, recordDTO.getBizType());
     }
    private void liked(Long userId, LikeRecordFormDTO recordDTO) {
        String key = LIKE_BIZ_KEY_PREFIX + recordDTO.getBizId();
        //将数据添加到redis中
        redisTemplate.opsForZSet().add(key, recordDTO.getBizType(),userId);
    }
}*/




























